{* $Id$ *}
{include_core file="admin/lib/header.html" title="角色展示"}
{if empty($search_filter) && empty($role_list) && $status != 0}
  <div class="search-none search-none-bg">
    <p>还没有角色发布，点击<a href="{AnUrl('role/admin/add')}" class="search-none-add">添加角色</a></p>
  </div>
{else}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">角色管理<span>在这里对角色进行管理</span></h2>
    <a href="{AnUrl('role/admin/add')}" class="btn btn-success btn-sm right"><i class="icon-add"></i>添加角色</a>
  </div>
  <div class="search-form js_advancedForm" {if $is_advenced == 0}style="display:none;"{/if}>
    <form action="role/admin" method="get" class="js_roleSearchForm">
      <input type="hidden" name="is_advenced" value="1">
      <input type="hidden" name="status" value="{$status}">
      <p>
        <label for="" class="search-f-label">角色标题：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[title]" value="{$search_filter.title}">
      </p>
      <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
  </div>
  <!--start:列表-->
  <table class="list-table">
    <caption>按状态：
      <a href='{AnUrl("role/admin?status=1")}' {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>正常</a>
      <a href='{AnUrl("role/admin?status=0")}' {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>已删除</a>
    </caption>
    <thead><tr>
      {if $status == 1}
      <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
      {/if}
      <th style="min-width:120px;">角色组名称</th>
      <th style="min-width:80px;">角色父级</th>
      <th style="width:60px;">角色类型</th>
      <th style="min-width:230px;">角色拥有权限</th>
      <th style="min-width:200px;">操作</th>
    </tr></thead>
    <tbody>
      {foreach $role_list as $k=>$v}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
          {if $status == 1}
          {if $v.type == 1}
          <td></td>
          {else}
          <td><input type="checkbox" class="listSelect"></td>
          {/if}
          {/if}
          <td>({$v.id}) {$v.title}</td>
          <td>
            {if role_helper::get_role_title($v.parent_id)}
              {role_helper::get_role_title($v.parent_id)}
            {else}
              无
            {/if}
          </td>
          <td>{role_config::$role_type[$v.type]}</td>
          <td>
            {if $v.privilege == '*'}
              所有权限
            {else}
              {if !$v.privilege}
                没有任何权限
              {else}
                {$privilege = explode(',', $v.privilege)}
                {foreach $privilege as $key=>$value}
                  <span class="btn btn-xs btn-default">
                    {admin_menu_helper::get_menu_title($value)}
                  </span>
                {/foreach}
              {/if}
            {/if}
          </td>
          <td>
            {if $status == 1}
              <a href='{AnUrl("role/admin/user_manage?id={$v.id}")}' class="btn btn-primary btn-xs">成员管理</a>
              <a href="{AnUrl("role/admin/edit?id={$v.id}")}" class="btn btn-info btn-xs" target="_self"><i class="icon-edit icon-white"></i>编辑</a>
              <a href="{AnUrl("role/admin/delete?id={$v.id}")}" class="btn btn-danger btn-xs deleteOne"><i class="icon-trash icon-white"></i>删除</a>
            {elseif $status == 0}
              <a href="{AnUrl("role/admin/change_status?status=1")}" class="btn btn-success btn-xs changeStatus"><i class="icon-trash icon-white"></i>恢复</a>
            {/if}
          </td>
        </tr>
      {foreachelse}
          <tr><td class="txtleft" colspan="6">暂无数据</td></tr>
      {/foreach}
    </tbody>
    {if $status}
    <tfoot><tr><td><input type="checkbox" class="selectAll"></td><td colspan="5"><a href="{AnUrl("role/admin/delete")}" class="btn btn-danger btn-xs deleteAll">批量删除</a></td></tr></tfoot>
    {/if}
  </table>
  {include_core file="admin/lib/pager.html"}
{/if}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}